package com.yidu.BusinessParament.controller;

import com.yidu.BusinessParament.entity.Plate;
import com.yidu.BusinessParament.entity.Security;
import com.yidu.BusinessParament.service.SecurityService;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *证券信息
 * @author :yimeng
 * @date :2022/12/5  16:04
 * @description:some description
 */
@RestController
public class SecurityController {
    @Resource
    private SecurityService service;


    //普通查询语句
    @RequestMapping("/selectSecurity1")
    public List<Security> selectSecurity1(Map map){
        return service.selectSecurity(map);
    }

    /**
     * 根据条件分页模糊查询
     * @param page  页面
     * @param limit 显示行数
     * @param security  证券实体类
     * @return  map 返回结果集
     */
    @RequestMapping("/limitSecurity")
    public Map limitSecurity(int page,int limit,Security security){
        System.out.println(security+"1111");
        List<Security> securities = service.limitSecurity(page, limit,security);
        for (Security security1 : securities) {
            System.out.println(security1);
        }
        //引用countSecurity查询总行数
        int i = service.countSecurity(security);
        System.out.println("page"+page);
        System.out.println("总行数"+i);
        HashMap map = new HashMap();
        map.put("code",0);
        map.put("msg","");
        map.put("count",i);
        map.put("data",securities);
        return map;
    }


    /**
     * 添加证券信息
     * @param security  证券实体类
     * @return
     */
    @RequestMapping("/insertSecurity")
    public int insertSecurity(Security security){
        return service.insertSecurity(security);
    }


    /**
     * 修改证券信息
     * @param security  证券实体类
     * @return
     */
    @RequestMapping("/update_Security")
    public int updateSecurity(Security security) {
        return service.updateSecurity(security);
    }


    /**
     * 根据证券编号进行单个删除
     * @param securityId    证券编号
     * @return
     */
    @RequestMapping("/deleteSecurity")
    public int deleteSecurity(String securityId){
        return service.deleteSecurity(securityId);
    }


    /**
     * 批量删除
     * @param securityId    证券编号
     * @return
     */
    @RequestMapping("/deleteMoreSecurity")
    public int deleteMoreSecurity(String securityId){
//        System.out.println("进行批量删除"+securityId);
        return service.deleteMoreSecurity(securityId);
    }


}
